/*
	Copyright 2007-2010 Petr Ohlidal

	This file is a part of GrobMaker

	GrobMaker is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	GrobMaker is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with GrobMaker.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef GROBMAKER_PIXEL
#define GROBMAKER_PIXEL

/** @file */

#include "../Global.hpp"
#include <sstream>
#include <cmath>

namespace GrobMaker{

/**
* @brief Class representing a color.
*/
struct Pixel{
	unsigned char r, g, b, a;

	Pixel(int r, int g, int b, int a){
		this->r = static_cast<unsigned char>(r);
		this->g = static_cast<unsigned char>(g);
		this->b = static_cast<unsigned char>(b);
		this->a = static_cast<unsigned char>(a);
	}

	/// Returns text description
    std::string toString(){
        std::stringstream ss;
        ss << "R:"<<std::abs(r)<<",G:"<<std::abs(g)<<",B:"<<std::abs(b)<<",A:"<<std::abs(a);
        return ss.str();
    }

    bool compareRGBA( Pixel &p ){ // compareTo
		return p.r==r && p.g==g && p.b==b && p.a==a;
	}

	bool compareRGB( const Pixel &p){
		return p.r==r && p.g==g && p.b==b;
	}

};

} // namespace GrobMaker

#endif //#ifndef GROBMAKER_PIXEL
